<template>
	<view class="flex_a padd_sx">
		<view :class="isIndex==index?'cat':''" @click="getClick(index)" v-for="(item,index) in props.list" :key="index">
			{{item.name}}
		</view>
	</view>
</template>

<script lang="ts">
	import { ref, defineComponent, onMounted } from 'vue'
	export default defineComponent({
		props: {
			list: Array
		},
		// emits: ['click'],
		setup(props, { emit }) {
			const isIndex = ref(0);
			console.log(props.list, 'list')
			// 点击事件
			const getClick = (index : number) => {
				isIndex.value = index
				emit('click', isIndex.value)
			}

			onMounted(() => {

			})
			return {
				props,
				isIndex,
				getClick
			}
		}
	})
</script>

<style lang="scss" scoped>
	.cat {
		color: aqua;
		position: relative;

		&:before {
			position: absolute;
			bottom: -20rpx;
			left: 50%;
			transform: translate(-50%);
			content: '';
			height: 10rpx;
			width: 50rpx;
			background-color: aqua;
			transition: 5s;
		}
	}
</style>